﻿package mortal.game.view.guildNew.info
{
    import Message.Public.*;
    import com.gengine.utils.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.component.window.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.guildNew.data.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class GuildNewInfoChangeName extends BaseWindow
    {
        private var _totalMo:int = 388;
        protected var _bg:ScaleBitmap;
        protected var _tip1:GTextFiled;
        protected var _tip2:GTextFiled;
        protected var _inputName:GTextInput;
        protected var _okBtn:GButton;
        protected var _cancelBtn:GButton;
        protected var _tip:GTextFiled;
        private static var _instance:GuildNewInfoChangeName;

        public function GuildNewInfoChangeName(param1:ILayer = null)
        {
            super(param1);
            setSize(283, 195);
            title = "" + Language.getString(71460);
            titleHeight = 60;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._bg = UIFactory.bg(8, 35, 274, 163, this, ImagesConst.PanelBg);
            this._tip1 = UIFactory.gTextField("", 23, 45, 260, 60, this, GlobalStyle.textFormatHuang2);
            this._tip1.multiline = true;
            this._tip1.wordWrap = true;
            this._tip2 = UIFactory.gTextField("" + Language.getString(71461), 47, 104, 200, 20, this, GlobalStyle.textFormatHuang2);
            this._inputName = UIFactory.gTextInput(66, 128, 160, 20, this);
            this._okBtn = UIFactory.gButton("" + Language.getString(71462), 76, 159, 50, 30, this);
            this._cancelBtn = UIFactory.gButton("" + Language.getString(71463), 156, 160, 50, 30, this);
            this._tip = UIFactory.gTextField("" + Language.getString(71464), 23, 83, 260, 20, this, GlobalStyle.textFormatHuang2);
            this._tip.text = Language.getStringByParam(71465, this._totalMo);
            this._tip1.htmlText = Language.getStringByParam(71466, 20);
            this._inputName.defaultText = "" + Language.getString(71467);
            this._okBtn.configEventListener(MouseEvent.CLICK, this.onChangOk);
            this._cancelBtn.configEventListener(MouseEvent.CLICK, this.onhideHd);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._bg = null;
            this._tip1 = null;
            this._tip2 = null;
            this._inputName = null;
            this._okBtn = null;
            this._cancelBtn = null;
            this._tip = null;
            super.disposeImpl(param1);
            return;
        }// end function

        private function onhideHd(event:MouseEvent) : void
        {
            this.hide();
            return;
        }// end function

        private function onChangOk(event:MouseEvent) : void
        {
            var _loc_2:* = this._inputName.text;
            var _loc_3:* = _loc_2;
            if (_loc_2 == null || _loc_2 == "")
            {
                MsgManager.showRollTipsMsg("" + Language.getString(71468));
                return;
            }
            _loc_2 = FilterText.instance.getFilterStr(_loc_2);
            if (_loc_2.indexOf("*") != -1)
            {
                this._inputName.text = _loc_2;
                MsgManager.showRollTipsMsg("" + Language.getString(71469));
                return;
            }
            if (Cache.instance.role.enoughMoney(EPriceUnit._EPriceUnitGold, this._totalMo) || Cache.instance.pack.backPackCache.getItemCountByCategoryAndType(EGroup._EGroupProp, EProp._EPropProp, EPropType._EPropTypeGuildNameCard) > 0)
            {
                Dispatcher.dispatchEvent(new DataEvent(GuildNewLocalEvent.GuildNewInfoChangeName, _loc_3));
            }
            else
            {
                MsgManager.showRollTipsMsg("" + Language.getString(71470));
            }
            return;
        }// end function

        public static function get instance() : GuildNewInfoChangeName
        {
            if (_instance == null)
            {
                _instance = new GuildNewInfoChangeName;
            }
            return _instance;
        }// end function

        public static function get isInShow() : Boolean
        {
            return _instance && !_instance.isHide;
        }// end function

    }
}
